package com.yuanfengerp.goodsInfoManage.controller;

import com.yuanfengerp.goodsInfoManage.model.ProductManagement;
import com.yuanfengerp.publicUtil.Result;
import org.apache.ibatis.annotations.Param;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.Map;

@RestController
public class ProductController {
    @Autowired
    private com.yuanfengerp.goodsInfoManage.servicer.IProductService productService;
    /**
     * 查询所有商品
     * @param params // 查询条件
     * @return Result // 查询结果
     */
    @PostMapping("/selectAllProduct")
    public Result<ArrayList> selectAllProduct(@RequestBody Map<String , Object > params){
        return productService.selectAllProduct(params);
    }

    /**
     *  新增商品
     * @param productManagement // 商品信息
     * @return Result // 返回结果
     */
    @PostMapping("/insertProduct")
    public Result<com.yuanfengerp.goodsInfoManage.model.ProductManagement> insertProduct(@RequestBody com.yuanfengerp.goodsInfoManage.model.ProductManagement productManagement){
        return productService.insertProduct(productManagement);
    }

    /**
     * 通过ID查询商品信息
     * @param productManagementId // 商品ID
     * @return Result // 查询结果
     */
    @PostMapping("/selectProductById")
    public Result<com.yuanfengerp.goodsInfoManage.model.ProductManagement> selectProductById(@RequestBody String productManagementId){
        return productService.selectProductById(productManagementId);
    }

    /**
     *  修改商品信息
     * @param productManagement // 商品信息
     * @return // 返回结果
     */
    @PostMapping("/updateProduct")
    public Result<com.yuanfengerp.goodsInfoManage.model.ProductManagement> updateProduct(@RequestBody com.yuanfengerp.goodsInfoManage.model.ProductManagement productManagement){
        return productService.updateProduct(productManagement);
    }

}
